package com.dawn.usermanage.serviceimpl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dawn.interestmanage.bean.InterestinfoBean;
import com.dawn.usermanage.bean.UserBean;
import com.dawn.usermanage.dao.UserManageDao;
import com.dawn.usermanage.service.UserManageService;
import com.dawn.utils.exceptions.DaoAccessException;

@Service
public class UserManageServiceImpl implements UserManageService {
    
    private static Logger logger = Logger.getLogger(UserManageServiceImpl.class);
    
    @Autowired
    private UserManageDao userManageDao;

    @Override
    public UserBean findUserByUID(int userId) {
        List<UserBean> users = userManageDao.findUserByUid(userId);
        if(!users.isEmpty()){
            UserBean user = users.get(0);
            return user;
        }
        return null;
    }

    @Override
    public UserBean findUserBySinaId(String sinaId) {
        List<UserBean> users = null;
        UserBean user = null;
        try {
            users = userManageDao.findUserBySId(sinaId);
            if(!users.isEmpty()){
                user = users.get(0);
            }
        } catch (Exception e) {
            logger.error("Data access error");
            e.printStackTrace();
            throw new DaoAccessException();
        }
        return user;
    }
    
  /* @Override
    public List<InterestinfoBean> findInterByUserId(int userId)
    {
        List<InterestinfoBean> interests = null;
        try {
        	interests = userManageDao.findInterByUserId(userId);
        } catch (Exception e) {
            logger.error("Data access error");
            e.printStackTrace();
            throw new DaoAccessException();
        }
        return interests;
    }
    */
}
